package com.sec.android.app.myfiles.feature.detailinfo;

import android.content.Context;
import android.view.View;

import com.sec.android.app.myfiles.module.abstraction.FileRecord;

import java.util.HashMap;

/**
 * Created by daesu83.kim on 2017-03-15.
 */

public class DetailsInfoMgr {

    private static DetailsInfoMgr sInstance;

    private HashMap<DetailsType, AbsDetailsInfoLoaderImp> mDetailsInfoLoaderImpMap;

    private enum DetailsType {
        CHILD_COUNT,
    }

    public static DetailsInfoMgr getInstance() {
        if (sInstance == null) {
            sInstance = new DetailsInfoMgr();
        }
        return sInstance;
    }

    private DetailsInfoMgr() {
        mDetailsInfoLoaderImpMap = new HashMap<>();
        mDetailsInfoLoaderImpMap.put(DetailsType.CHILD_COUNT, new ChildCountLoaderImp());
    }

    public void loadChildCount(Context context, FileRecord record, View view) {
        if (view == null) {
            return;
        }
        AbsDetailsInfoLoaderImp childCountLoader = mDetailsInfoLoaderImpMap.get(DetailsType.CHILD_COUNT);
        childCountLoader.loadDetailsInfo(context, record, view);
    }

    public void clearChildCountCache(FileRecord fileRecord) {
        AbsDetailsInfoLoaderImp childCountLoader = mDetailsInfoLoaderImpMap.get(DetailsType.CHILD_COUNT);
        childCountLoader.clearCache(fileRecord);
    }
}
